import Vue from 'vue'
import VueRouter from 'vue-router'
import AboutView from '../views/AboutView.vue'
import IndexView from '../views/IndexView.vue'
import CategoryView from '../views/CategoryView.vue'
import TagView from '../views/TagView.vue'
import ArchiveView from '../views/ArchiveView.vue'
import ArticleDetail from '@/views/ArticleDetail.vue';
import CategoryList from '../views/CategoryList.vue';
import AfterView from '../views/AfterView.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/about'
  },
  {
    path: '/about',
    name: 'about',
    component: AboutView,
    children: [
      {
        path: 'index',
        name: 'index',
        component: IndexView
      },
      {
        path: 'category',
        name: 'category',
        component: CategoryView
      },
      {
        path: 'tag',
        name: 'tag',
        component: TagView
      },
      {
        path: 'archive',
        name: 'archive',
        component: ArchiveView
      },
      {
        path: '',
        redirect: 'index'
      },
      {
        path: 'article/:id',
        name: 'ArticleDetail',
        component: ArticleDetail
      },

      {
        path: 'category/list',
        name: 'CategoryList',
        component: CategoryList

      }
    ]
  }, {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  }
  , {
    path: '/after',
    name: 'after',
     component: AfterView,

    children: [
      {
        path: 'watch',
        name: 'watch',
        component: () => import('../views/NewWatch.vue'),
      },{
        path: 'text',
        name: 'text',
        component: () => import('../views/NewText.vue'),
      },
      {
        path: 'cate',
        name: 'cate',
        component: () => import('../views/NewCate.vue'),
      },{
        path: 'tage',
        name: 'tage',
        component: () => import('../views/NewTage.vue'),
      },{
        path: 'web',
        name: 'web',
        component: () => import('../views/NewWeb.vue'),
      },

    ]
  },
]
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => {
    if (err.name !== 'NavigationDuplicated') throw err
  })
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router